home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
090
/
code39.arc
/
CODE39.BAS
next >
Wrap
BASIC Source File
|
1986-09-16
|
13KB
|
268 lines
10 '**************************************************************************
20 '***** CODE 3-of-9 BAR CODE GENERATOR *****
30 '***** ******************************* *****
40 '***** This program will generate standard 3-of-9 bar code *****
50 '***** on any dot matrix printer which is compatable with *****
60 '***** an Epson or IBM graphics printer. *****
70 '***** ****************************** *****
80 '***** - SPECIFICATIONS - *****
90 '** **
100 '** W N **
110 '** | Nominal Width | Nominal Width | Nominal Ratio **
120 '** Density | of | of | of **
130 '** (Characters/ | Narrow Bars and | Wide Bars and | Wide to Narrow **
140 '** Inch) | Spaces (Inches) | Spaces (Inches)| Element Width **
150 '** -------------+-----------------+----------------+---------------- **
160 '** 5.730 | 0.0125 | 0.0315 | 2.52 **
170 '** -------------+-----------------+----------------+---------------- **
180 '** **
190 '***** ****************************** *****
200 '***** Code 3-of-9 was developed in 1974 by Dr. David C. Allais of *****
210 '***** Interface Mechanisms, Inc. It has been adopted as the *****
220 '***** standard bar code symbology of the Department of Defence *****
230 '***** (MIL-STD-1189) and is the most widely used alphanumeric bar *****
240 '***** code in use. Code 3-of-9 is so called because the original *****
250 '***** concept provided for 39 data characters. The name also *****
260 '***** describes the structure of the code which has 3 wide elements *****
270 '***** out of a total of 9. *****
280 '***** *****
290 '***** For best results use only even numbered values for height *****
300 '***** and use a height which is approx 15% of the total code *****
310 '***** length. *****
320 '***** *****
330 '***** This program was written solely for information purposes to *****
340 '***** demonstrate the structure of code 3-of-9. The author is *****
350 '***** not responsible for any damages incurred through the use of *****
360 '***** this program. *****
370 '***** *****
380 '***** Bill Wood Milwaukee, WI 05/18/85 *****
390 '**************************************************************************
400 '
410 DIM X(30),M(30),P$(30),A$(30)
420 '
430 '***** generate data entry screen
440 '
450 KEY OFF
460 CLS
470 COLOR 7
480 PRINT "╔═════════════════════════════════════╗"
490 FOR P=1 TO 3
500 PRINT "║ ║"
510 NEXT P
520 PRINT "╠═════════════════════════════════════╣
530 FOR P=1 TO 5
540 PRINT "║ ║"
550 NEXT P
560 PRINT "╚═════════════════════════════════════╝"
570 '
580 '***** display menu and get input from user
590 '
600 LOCATE 3,5 :COLOR 4 :PRINT "CODE 3-OF-9 BAR CODE GENERATOR"
610 LOCATE 6,3 :COLOR 6 :PRINT "1 Print Data from CONSOLE"
620 LOCATE 7,3 :COLOR 6 :PRINT "2 Print Data from FILE "
630 LOCATE 8,3 :COLOR 6 :PRINT "3 ADD Data to FILE "
640 LOCATE 9,3 :COLOR 6 :PRINT "Q QUIT "
650 LOCATE 10,10:COLOR 6 :PRINT "==>"
660 LOCATE 10,14:COLOR 10:INPUT " ",SELECT$
670 IF SELECT$="Q" THEN GOTO 1940
680 GOSUB 2260
690 IF SELECT$="1" THEN GOTO 730
700 IF SELECT$="2" THEN GOTO 740
710 IF SELECT$="3" THEN GOTO 750
720 GOTO 450
730 GOSUB 1990 :GOSUB 790 :GOTO 450
740 OPEN "CODE39.DAT" FOR INPUT AS #1 :GOTO 2070
750 OPEN "CODE39.DAT" FOR APPEND AS #1 :GOTO 2170
760 '
770 '***** add start and stop characters to user message (*)
780 '
790 MSG$="*"+MSG$+"*" :S$=""
800 '
810 '***** define print head pins to fire
820 '
830 NS$=CHR$(0)+CHR$(0)
840 WS$=CHR$(0)+CHR$(0)+CHR$(0)+CHR$(0)
850 NB$=CHR$(255)
860 WB$=CHR$(255)+CHR$(255)+CHR$(255)
870 '
880 '***** CHECK FOR ONLY CAPITAL LETTERS
890 '
900 GOSUB 2320
910 '
920 '***** decode message into bar code
930 '
940 L=LEN(MSG$)
950 FOR X=1 TO L
960 TEST$=MID$(MSG$,X,1)
970 IF TEST$="1" THEN L$=WB$+NS$+NB$+WS$+NB$+NS$+NB$+NS$+WB$ :GOTO 1470
980 IF TEST$="2" THEN L$=NB$+NS$+WB$+WS$+NB$+NS$+NB$+NS$+WB$ :GOTO 1470
990 IF TEST$="3" THEN L$=WB$+NS$+WB$+WS$+NB$+NS$+NB$+NS$+NB$ :GOTO 1470
1000 IF TEST$="4" THEN L$=NB$+NS$+NB$+WS$+WB$+NS$+NB$+NS$+WB$ :GOTO 1470
1010 IF TEST$="5" THEN L$=WB$+NS$+NB$+WS$+WB$+NS$+NB$+NS$+NB$ :GOTO 1470
1020 IF TEST$="6" THEN L$=NB$+NS$+WB$+WS$+WB$+NS$+NB$+NS$+NB$ :GOTO 1470
1030 IF TEST$="7" THEN L$=NB$+NS$+NB$+WS$+NB$+NS$+WB$+NS$+WB$ :GOTO 1470
1040 IF TEST$="8" THEN L$=WB$+NS$+NB$+WS$+NB$+NS$+WB$+NS$+NB$ :GOTO 1470
1050 IF TEST$="9" THEN L$=NB$+NS$+WB$+WS$+NB$+NS$+WB$+NS$+NB$ :GOTO 1470
1060 IF TEST$="0" THEN L$=NB$+NS$+NB$+WS$+WB$+NS$+WB$+NS$+NB$ :GOTO 1470
1070 IF TEST$="A" THEN L$=WB$+NS$+NB$+NS$+NB$+WS$+NB$+NS$+WB$ :GOTO 1470
1080 IF TEST$="B" THEN L$=NB$+NS$+WB$+NS$+NB$+WS$+NB$+NS$+WB$ :GOTO 1470
1090 IF TEST$="C" THEN L$=WB$+NS$+WB$+NS$+NB$+WS$+NB$+NS$+NB$ :GOTO 1470
1100 IF TEST$="D" THEN L$=NB$+NS$+NB$+NS$+WB$+WS$+NB$+NS$+WB$ :GOTO 1470
1110 IF TEST$="E" THEN L$=WB$+NS$+NB$+NS$+WB$+WS$+NB$+NS$+NB$ :GOTO 1470
1120 IF TEST$="F" THEN L$=NB$+NS$+WB$+NS$+WB$+WS$+NB$+NS$+NB$ :GOTO 1470
1130 IF TEST$="G" THEN L$=NB$+NS$+NB$+NS$+NB$+WS$+WB$+NS$+WB$ :GOTO 1470
1140 IF TEST$="H" THEN L$=WB$+NS$+NB$+NS$+NB$+WS$+WB$+NS$+NB$ :GOTO 1470
1150 IF TEST$="I" THEN L$=NB$+NS$+WB$+NS$+NB$+WS$+WB$+NS$+NB$ :GOTO 1470
1160 IF TEST$="J" THEN L$=NB$+NS$+NB$+NS$+WB$+WS$+WB$+NS$+NB$ :GOTO 1470
1170 IF TEST$="K" THEN L$=WB$+NS$+NB$+NS$+NB$+NS$+NB$+WS$+WB$ :GOTO 1470
1180 IF TEST$="L" THEN L$=NB$+NS$+WB$+NS$+NB$+NS$+NB$+WS$+WB$ :GOTO 1470
1190 IF TEST$="M" THEN L$=WB$+NS$+WB$+NS$+NB$+NS$+NB$+WS$+NB$ :GOTO 1470
1200 IF TEST$="N" THEN L$=NB$+NS$+NB$+NS$+WB$+NS$+NB$+WS$+WB$ :GOTO 1470
1210 IF TEST$="O" THEN L$=WB$+NS$+NB$+NS$+WB$+NS$+NB$+WS$+NB$ :GOTO 1470
1220 IF TEST$="P" THEN L$=NB$+NS$+WB$+NS$+WB$+NS$+NB$+WS$+NB$ :GOTO 1470
1230 IF TEST$="Q" THEN L$=NB$+NS$+NB$+NS$+NB$+NS$+WB$+WS$+WB$ :GOTO 1470
1240 IF TEST$="R" THEN L$=WB$+NS$+NB$+NS$+NB$+NS$+WB$+WS$+NB$ :GOTO 1470
1250 IF TEST$="S" THEN L$=NB$+NS$+WB$+NS$+NB$+NS$+WB$+WS$+NB$ :GOTO 1470
1260 IF TEST$="T" THEN L$=NB$+NS$+NB$+NS$+WB$+NS$+WB$+WS$+NB$ :GOTO 1470
1270 IF TEST$="U" THEN L$=WB$+WS$+NB$+NS$+NB$+NS$+NB$+NS$+WB$ :GOTO 1470
1280 IF TEST$="V" THEN L$=NB$+WS$+WB$+NS$+NB$+NS$+NB$+NS$+WB$ :GOTO 1470
1290 IF TEST$="W" THEN L$=WB$+WS$+WB$+NS$+NB$+NS$+NB$+NS$+NB$ :GOTO 1470
1300 IF TEST$="X" THEN L$=NB$+WS$+NB$+NS$+WB$+NS$+NB$+NS$+WB$ :GOTO 1470
1310 IF TEST$="Y" THEN L$=WB$+WS$+NB$+NS$+WB$+NS$+NB$+NS$+NB$ :GOTO 1470
1320 IF TEST$="Z" THEN L$=NB$+WS$+WB$+NS$+WB$+NS$+NB$+NS$+NB$ :GOTO 1470
1330 IF TEST$="-" THEN L$=NB$+WS$+NB$+NS$+NB$+NS$+WB$+NS$+WB$ :GOTO 1470
1340 IF TEST$="." THEN L$=WB$+WS$+NB$+NS$+NB$+NS$+WB$+NS$+NB$ :GOTO 1470
1350 IF TEST$=" " THEN L$=NB$+WS$+WB$+NS$+NB$+NS$+WB$+NS$+NB$ :GOTO 1470
1360 IF TEST$="*" THEN L$=NB$+WS$+NB$+NS$+WB$+NS$+WB$+NS$+NB$ :GOTO 1470
1370 IF TEST$="$" THEN L$=NB$+WS$+NB$+WS$+NB$+WS$+NB$+NS$+NB$ :GOTO 1470
1380 IF TEST$="/" THEN L$=NB$+WS$+NB$+WS$+NB$+NS$+NB$+WS$+NB$ :GOTO 1470
1390 IF TEST$="+" THEN L$=NB$+WS$+NB$+NS$+NB$+WS$+NB$+WS$+NB$ :GOTO 1470
1400 IF TEST$="%" THEN L$=NB$+NS$+NB$+WS$+NB$+WS$+NB$+WS$+NB$ :GOTO 1470
1410 '
1420 '***** print error message if input is invalid
1430 '
1440 LOCATE 7,3 :COLOR 11 :PRINT " INVALID CHARACTER DETECTED!!! "
1450 LOCATE 9,3 :COLOR 28 :PRINT " ";TEST$;" "
1460 LOCATE 15,8 :COLOR 14 :PRINT "*** PROCESSING ABORTED ***":GOTO 1940
1470 P$(X)=L$
1480 '
1490 '***** develop human readable text to be printed under bar code
1500 '
1510 A$(X)=TEST$
1520 IF X=15 OR X=25 THEN GOTO 1540
1530 IF X>2 AND (X MOD 2)>0 THEN S$=S$+" "
1540 NEXT X
1550 '
1560 '***** set printer to 2/216 lines per inch
1570 '
1580 WIDTH "LPT1:",255
1590 LPRINT CHR$(27);CHR$(51);CHR$(2);
1600 '
1610 '***** calculate N1 and N2 values for dot graphics command
1620 '
1630 COLS=21
1640 N1=COLS MOD 256
1650 N2=FIX(COLS/256)
1660 '
1670 '***** print each character of bar code
1680 '
1690 LOCATE 7,3 :COLOR 1 :PRINT "PRINTING- "
1700 HIGH=ABS(HIGH):IF HIGH=0 THEN HIGH=2
1710 FOR H=1 TO HIGH
1720 FOR N=L TO 1 STEP -1
1730 LOCATE 7,(N+12) :PRINT " "
1740 NEXT N
1750 FOR M=1 TO L
1760 LOCATE 7,(M+11) :COLOR 11 :PRINT A$(M)
1770 LPRINT CHR$(27);CHR$(76);CHR$(N1);CHR$(N2);P$(M);NS$;
1780 NEXT M
1790 '
1800 '***** set printer to 19/216 lines per inch every other line
1810 '
1820 IF (H MOD 2)=0 THEN LPRINT CHR$(27);CHR$(74);CHR$(19);
1830 LPRINT " "
1840 LOCATE 9,3 :COLOR 1 :PRINT " PASS-"
1850 LOCATE 9,12 :COLOR 11 :PRINT H
1860 LOCATE 9,15 :COLOR 1 :PRINT " COMPLETE "
1870 NEXT H
1880 '
1890 '***** reset printer to default and print human readable text
1900 '
1910 LPRINT CHR$(27);"2",CHR$(27);"E"
1920 LPRINT S$;MSG$
1930 RETURN
1940 LOCATE 20,1 :COLOR 7,0,0 :PRINT
1950 END
1960 '
1970 '***** enter data from console
1980 '
1990 LOCATE 7,3 :COLOR 6 :PRINT "ENTER MESSAGE:"
2000 LOCATE 7,17 :COLOR 10:INPUT " ",MSG$
2010 LOCATE 9,3 :COLOR 6 :PRINT " ENTER HEIGHT:"
2020 LOCATE 9,17 :COLOR 10:INPUT " ",HIGH
2030 RETURN
2040 '
2050 '***** read data from file
2060 '
2070 LOCATE 9,3 :COLOR 6 :PRINT " ENTER HEIGHT:"
2080 LOCATE 9,17 :COLOR 10:INPUT " ",HIGH
2090 GOSUB 2260
2100 INPUT #1,MSG$
2110 GOSUB 790
2120 IF EOF(1) THEN CLOSE #1 :GOTO 450
2130 GOTO 2100
2140 '
2150 '***** write data to file
2160 '
2170 LOCATE 7,3 :COLOR 6 :PRINT "ENTER MESSAGE (press enter to quit) "
2180 LOCATE 9,10 :COLOR 6 :PRINT "==> "
2190 LOCATE 9,14 :COLOR 10:INPUT " ",MSG$
2200 IF MSG$="" THEN CLOSE #1 :GOTO 450
2210 PRINT #1,MSG$ :GOSUB 2260
2220 GOTO 2170
2230 '
2240 '***** clear data entry area
2250 '
2260 LOCATE 6,2 :PRINT " "
2270 LOCATE 7,2 :PRINT " "
2280 LOCATE 8,2 :PRINT " "
2290 LOCATE 9,2 :PRINT " "
2300 LOCATE 10,2 :PRINT " "
2310 RETURN
2320 '
2330 '***** CHECK FOR ONLY CAPITAL LETTERS
2340 ED$ = ""
2350 L = LEN(MSG$)
2360 FOR X = 1 TO L
2370 TEST$=MID$(MSG$,X,1)
2380 IF TEST$="a" THEN TEST$="A" : GOTO 2640
2390 IF TEST$="b" THEN TEST$="B" : GOTO 2640
2400 IF TEST$="c" THEN TEST$="C" : GOTO 2640
2410 IF TEST$="d" THEN TEST$="D" : GOTO 2640
2420 IF TEST$="e" THEN TEST$="E" : GOTO 2640
2430 IF TEST$="f" THEN TEST$="F" : GOTO 2640
2440 IF TEST$="g" THEN TEST$="G" : GOTO 2640
2450 IF TEST$="h" THEN TEST$="H" : GOTO 2640
2460 IF TEST$="i" THEN TEST$="I" : GOTO 2640
2470 IF TEST$="j" THEN TEST$="J" : GOTO 2640
2480 IF TEST$="k" THEN TEST$="K" : GOTO 2640
2490 IF TEST$="l" THEN TEST$="L" : GOTO 2640
2500 IF TEST$="m" THEN TEST$="M" : GOTO 2640
2510 IF TEST$="n" THEN TEST$="N" : GOTO 2640
2520 IF TEST$="o" THEN TEST$="O" : GOTO 2640
2530 IF TEST$="p" THEN TEST$="P" : GOTO 2640
2540 IF TEST$="q" THEN TEST$="Q" : GOTO 2640
2550 IF TEST$="r" THEN TEST$="R" : GOTO 2640
2560 IF TEST$="s" THEN TEST$="S" : GOTO 2640
2570 IF TEST$="t" THEN TEST$="T" : GOTO 2640
2580 IF TEST$="u" THEN TEST$="U" : GOTO 2640
2590 IF TEST$="v" THEN TEST$="V" : GOTO 2640
2600 IF TEST$="w" THEN TEST$="W" : GOTO 2640
2610 IF TEST$="x" THEN TEST$="X" : GOTO 2640
2620 IF TEST$="y" THEN TEST$="Y" : GOTO 2640
2630 IF TEST$="z" THEN TEST$="Z" : GOTO 2640
2640 ED$=ED$+TEST$
2650 NEXT X
2660 MSG$ = ED$
2670 RETURN